package cn.chen.proxy.compiler;

import java.lang.reflect.Method;

public class TimeHander implements InvocationHander {

    private Object target;

    public TimeHander(Object target) {
        this.target = target;
    }

    @Override
    public void invoke(Object o,Method method) {
        long start = System.currentTimeMillis();
        System.out.println("开始：" + start);
        System.out.println(o.getClass().getName());
        try {
            method.invoke(target,new Object[]{});
        } catch (Exception e) {
            e.printStackTrace();
        }

        long end = System.currentTimeMillis();
        System.out.println("运行：" + (start - end));
    }

}
